﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DAL;

namespace BLL
{
    public class ForLogin
    {
        //管理员登录
        public bool ManagerLogin(string LoginID,string Pwd)
        {
            //默认登录登录失败
            bool isValid = false;
            string sql = string.Format(@"select ManageID from Admin 
                            where ManageID = '{0}' and Pwd = '{1}';",
                            LoginID, Pwd);

            string iRet = Convert.ToString(DBHelper.ExecuteScalar(sql));
            if (!iRet.Equals(string.Empty) && !iRet.Equals("-1"))
            {
                //存储登录用户名
                StaticStore.loginName = "管理员：" + iRet;
                StaticStore.managerID = LoginID;
                isValid = true;
            }
            return isValid;
        }
        //读者登录
        public bool ReaderLogin(string LoginID, string Pwd)
        {
            //默认登录登录失败
            bool isValid = false;

            string sql = string.Format(@"select ReaderName from Reader 
                            where ReaderID = '{0}' and Pwd = '{1}';",
                            LoginID, Pwd);

            string iRet = Convert.ToString(DBHelper.ExecuteScalar(sql));

            if (!iRet.Equals(string.Empty) && !iRet.Equals("-1"))
            {
                //存储登录用户名
                StaticStore.loginName = "读者：" + iRet;
                StaticStore.readerID = LoginID;
                isValid = true;
            }

            return isValid;
        }
    }
}
